package Control;

import Model.User;
import Model.User_Director;
import Model.User_Staff;
import Model.User_Visitor;

import java.util.Scanner;

public class register {

    static Scanner s = new Scanner(System.in);

    //用于控制用户注册功能
    //参数：无
    //返回值：User类
    public static User registerPage() {

        System.out.println("您是：");
        System.out.println("1-游客");
        System.out.println("2-动物饲养员");
        System.out.println("3-园长");
        System.out.print("请选择：");
        int num = s.nextInt();
        switch (num) {
            case 1:
                System.out.println("1-游客");
                User_Visitor u1 = new User_Visitor();
                u1.setId("游客");
                u1 = (User_Visitor) input(u1);
                return u1;
            case 2:
                System.out.println("2-动物饲养员");
                User_Staff u2 = new User_Staff();
                u2.setId("动物饲养员");
                u2 = (User_Staff) input(u2);
                return u2;
            case 3:
                System.out.println("3-园长");
                User_Director u3 = new User_Director();
                u3.setId("园长");
                u3 = (User_Director) input(u3);
                return u3;
        }
        return null;
    }

    //用于创建用户时数据输入
    //参数：User对象
    //返回值：User对象
    private static User input(User u) {

        System.out.println("请输入用户名：");
        u.setName(s.next());
        System.out.println("请输入身份证号码：");
        u.setIdNumber(s.next());
        System.out.println("请输入密码：");
        u.setCode(s.next());
        System.out.println("请输入联系方式：");
        u.setPhoneNumber(s.next());
        System.out.println("注册成功");
        return u;

    }



}
